package com.dev;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.graphics.drawable.ColorDrawable;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.Gravity;
import android.view.View.OnClickListener;
import android.view.View;
public class GUIChromeSettings extends LinearLayout implements OnClickListener{
	MainActivity ma;
	LinearLayout titlebar;
	LinearLayout itMainPage;
	TextView title1;
	LayoutParams titlebarlp;
	LayoutParams itlp;
	IconView ivQuit;
    GUIChromeSettings(MainActivity ma){
		super(ma);
		this.ma=ma;
		ivQuit=new IconView(ma);
		ivQuit.setImageResource(R.drawable.ic_quit_thin);
		ivQuit.setOnClickListener(this);
		titlebar=new LinearLayout(ma);
		titlebar.setOrientation(HORIZONTAL);
		titlebar.setBackgroundColor(ma.titlebarBackgroundColor);
		titlebar.addView(ivQuit);
		titlebarlp=new LayoutParams(-1,ma.titlebarHeight);
		itMainPage=new LinearLayout(ma);
		itMainPage.setOrientation(HORIZONTAL);
		itMainPage.setBackground(new UnderlineBackground());
		itlp=new LayoutParams(-1,ma.dialogTitleBarHeight);
		final float titleTextSize=(int)(13*ma.dp);
		title1=new TextView(ma);
		title1.setText("主页");
		title1.setTextColor(0xff000000);
		title1.setTextSize(titleTextSize);
		title1.setGravity(Gravity.CENTER_VERTICAL);
		itMainPage.addView(title1,-2,-1);
		addView(titlebar,titlebarlp);
		addView(itMainPage,itlp);
	}
	@Override
	public void onClick(View view) {
		if(view==ivQuit){
			ma.setContentView(ma.gui);
		}
	}
	static class UnderlineBackground extends ColorDrawable{
		@Override 
		public void draw(Canvas canvas){
			int cw=canvas.getWidth();
			int ch=canvas.getHeight();
			Paint p=new Paint();
			p.setColor(0x77888888);
			int strokeWidth=2;
			canvas.drawRect(0,ch-strokeWidth,cw,ch,p);
		}
	}
}
